package interceptor;

import java.util.Map;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

/**
 * @author dingyuanwei
 * @version 建立時間：Dec 24, 201011:25:19 AM
 * 類別說明:登录拦截器
 */
public class LoginInterceptor extends AbstractInterceptor {

	@Override
	public String intercept(ActionInvocation ai) throws Exception {
		Map session = ai.getInvocationContext().getSession();
		String username = (String) session.get("user");
		if(username !=null && username.length() > 0){
			return ai.invoke();
			
		}else{
			ActionContext ac = ai.getInvocationContext();
		
			ac.getApplication().put("popedon", "您还没有登录，请登录");
		    return Action.LOGIN;
		}
	}

}
